package com.itheima.pojo;

import com.fasterxml.jackson.annotation.JsonSetter;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {

    private Integer id;
    private String name;
    private Integer gender;
    private String username;
    private String password;
    private Integer role;
    private String phone;
    // 状态 0-否 1-有
    private Integer status;
    private LocalDateTime createTime;

    @JsonSetter
    public void setGender(String gender) {
        if (gender != null && !gender.isEmpty()) {
            this.gender = Integer.valueOf(gender);
        }
    }

    @JsonSetter
    public void setRole(String role) {
        if (role != null && !role.isEmpty()) {
            this.role = Integer.valueOf(role);
        }
    }

    @JsonSetter
    public void setStatus(String status) {
        if (status != null && !status.isEmpty()) {
            this.status = Integer.valueOf(status);
        }
    }
}
